package com.ygbhu.design.abstractfac;

import com.ygbhu.design.abstractfac.service.PhoneService;
import com.ygbhu.design.abstractfac.service.ProductFactoryService;
import com.ygbhu.design.abstractfac.service.RouterService;
import com.ygbhu.design.abstractfac.service.impl.huawei.HuaweiProductImpl;
import com.ygbhu.design.abstractfac.service.impl.xiaomi.XiaomiProductImpl;

/**
 * @program: design-pattern
 * @description: 抽象工厂模式，适合固定产品系列，如果有个性化变更，效率很低
 * @author: smzhu3
 * @create: 2021-06-17 11:51
 **/
public class Test {
    public static void main(String[] args) {
        System.out.println("<***************小米工厂***************>");
        //小米工厂
        ProductFactoryService xiaomiProduct = new XiaomiProductImpl();
        PhoneService xiaomiPhone = xiaomiProduct.productPhone();
        xiaomiPhone.start();
        xiaomiPhone.shutDown();
        RouterService xiaomiRouter = xiaomiProduct.productRouter();
        xiaomiRouter.start();
        xiaomiRouter.shutDown();

        System.out.println("<***************华为工厂***************>");
        //华为工厂
        ProductFactoryService huaweiProduct = new HuaweiProductImpl();

        PhoneService huaweiPhone = huaweiProduct.productPhone();
        huaweiPhone.start();
        huaweiPhone.shutDown();
        RouterService huaweiRouter = huaweiProduct.productRouter();
        huaweiRouter.start();
        huaweiRouter.shutDown();
    }
}
